<?php
/*
学生管理模块
*/
include_once('include/top.php');
/* css	*/	
require_once('../include/comm_include_for_css.php');
/* js	*/	
//echo('<script src="'.fs_get_root_a().''.DIR_RESOURCES.'/js/jquery-1.5.1.min.js"></script>');

$action=fs_get_value("do");
switch($action)
{
	case	"addmember"	     : addmember()	         ; break;
        case	"addteacher"	     : addteacher()	         ; break;
	case	"add"	         : do_addmember()	     ; break;
	case	"delete"	     : delete_member()	     ; break;
	case    "searchmember"   : searchmember()        ; break;
	case    "batchadd"       : batchadd()            ; break;         //批量添加
	case    "do_batchadd"    : do_batchadd()         ; break;
	default				     : main()		         ; break;
}
?>
<script type="text/javascript">
  function getOptionDEPARTMENT(){
  $.getJSON("option.php",{'departmentid':$("#dueid").val()},function(data){
    $("#departid").html("<option value='-1'>请选择系</option>");
    $("#majorid").html("<option value=''>请选择专业</option>");
    $("#classid").html("<option value=''>请选择班级</option>");
    $.each(data, function(index,array){
     var option="<option value='"+array['id']+"'>"+array['name']+"</option>"; 
     $("#departid").append(option);
    });                
   }); 
 }
 function getOptionMAJOR(){
  $.getJSON("option.php",{'bval':$("#departid").val()},function(data){
    $("#majorid").empty();//每次选择前，清空小类的值。
    $("#classid").empty();
    $("#classid").html("<option value='-1'>请选择班级</option>");
    $("#majorid").html("<option value='-1'>请选择专业</option>");
    $.each(data, function(index,array){
     var option="<option value='"+array['id']+"'>"+array['name']+"</option>"; 
     $("#majorid").append(option);
    });                
   }); 
 }
  function getOptionCLASS(){
  $.getJSON("option.php",{'classid':$("#majorid").val(),'dueid':$("#dueid").val()},function(data){
    $("#classid").empty();//每次选择前，清空小类的值。
    $("#classid").html("<option value='-1'>请选择班级</option>");
    $.each(data, function(index,array){
     var option="<option value='"+array['id']+"'>"+array['name']+"</option>"; 
     $("#classid").append(option);
    });                
   }); 
 }
 $(document).ready(function(){
    $("#dueid").change(function(){
        getOptionDEPARTMENT();
    });
    $("#departid").change(function(){
        getOptionMAJOR();
    });
    $("#majorid").change(function(){
        getOptionCLASS();
    });
 });
</script>

<?php

function main()
{
    global $db;
	$member_name = fs_get_value("member_name");
	$username = fs_get_value("username");
	$tel = fs_get_value("tel");
	$email = fs_get_value("email");
	$money = fs_get_value("money");
	$payed = fs_get_value("payed");
	$state = fs_get_value("state");
	$logintimes = fs_get_value("logintimes");
	$lastlogintime = fs_get_value("lastlogintime");
	$onlinetime = fs_get_value("onlinetime");
	$registerdate = fs_get_value("registerdate");
	$conditionarray = array($member_name,$username,$tel,$email,$money,$payed,$state,$logintimes,$lastlogintime,$olinetime,$registerdate);
	$valuearray = array(" and realname like '%".$member_name."%'"," and passport like '%".$username."%'"," and tel like '%".$tel."%'"," and email like '%".$email."%'"," and money = ".$money," and payed = ".$payed," and state = ".$state," and logintimes = ".$logintimes," and lastlogintime like '%".$lastlogintime."%'"," and onlinetime = ".$onlinetime," and registerdate = ".strtotime($registerdate));
	$sql = "select * from nettteach_member where type = '3'";
	for($i=0;$i<count($conditionarray);$i++ ){
		if($conditionarray[$i] == ''){
			$valuearray[$i] = '';
		}
		$sql.=$valuearray[$i];
	}
        $dueid = fs_get_value("dueid");
        $departid = fs_get_value("departid");
        $majorid = fs_get_value("majorid");
        $classid = fs_get_value("classid");
        if($dueid != '-1' && $dueid != '')
        {
             $sql.= "  and classid in (select id from nettteach_class where dueid =".$dueid.")";   
        }
        if($departid != '-1' && $departid != '')
        {
             $sql.= "  and classid in (select id from nettteach_class where departmentid =".$departid.")";
        }
        if($majorid != '-1' && $majorid != '')
        {
             $sql.= "  and classid in (select id from nettteach_class where majorid =".$majorid.")";
        }
        if($classid != '-1' && $classid != '')
        {
             $sql.= "  and classid = '".$classid."'";   
        }
        $sql.=" order by classid";
	$member_result = $db -> query($sql);
	$recordcount = $db -> num_rows($member_result);
	@$page=$_GET['p'];
	if ($page==null){$page=1;}
	$pagesize=50;								//每页显示数
	$pagecount=ceil($recordcount/$pagesize);	//计算总页
	if ($page>$pagecount){$page=$pagecount;}
	if ($page<1){$page=1;}
?>
<script src="./js/Main.js"></script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="CContent">
  <tr>
    <th class="CTitle">学生管理</th>
  </tr>
  <tr>
    <td class="CPanel">
    <div class="SubMenu">
		<a href="teacher_student.php?">学生管理</a> | 
		<a href="teacher_student.php?do=addteacher">添加学生</a> | 
		<a href="teacher_student.php?do=searchmember">搜索学生</a> | 
		<a href="teacher_student.php?do=batchadd">批量导入</a>
	</div>
	
	<form action="?do=delete" method="post" name="fooeeform" style="margin:0px">
		<table border="0" cellpadding="0" cellspacing="0"  class="TablePanel" width="100%">
			<tr align="center" class="TDHead">
				<td nowrap><input type=button style="font-size:9pt;width:50px;" value="全选" onclick="click_allid(fooeeform,1)"/></td>
				<td nowrap><input type=button style="font-size:9pt;width:60px;" value="全取消" onclick="click_allid(fooeeform,0)"/></td>
				<td nowrap><input type="submit" style="font-size:9pt;width:50px;" value="删除" onclick="return delid()"/></td>

				<td nowrap width="500"><input type=button style="font-size:9pt;width:80px;" onclick="window.location.href('teacher_student.php?do=searchmember')" value="搜索学生" />
				</td>
				<td nowrap>.</td>
				<td nowrap>.</td>
				<td width="30%" nowrap></td>
				<td nowrap></td>
			</tr>
		</table>
<div id="click_idall">
    <div align="left" style="padding:5px;">
      <table border="0" cellpadding="0" cellspacing="0" class="TablePanel" align="center" width="100%">
        <tr align="center">
		  <td class="TDHead">√</td>
          <td class="TDHead" nowrap>登陆账号</td>
          <td class="TDHead" nowrap>学生姓名</td>
          <td class="TDHead" nowrap>届</td>
          <td class="TDHead" nowrap>班级</td>
          <td class="TDHead" nowrap>系/专业</td>
          <td class="TDHead" nowrap>联系电话</td>
          <td class="TDHead" nowrap>电子邮箱</td>
		  <td class="TDHead" nowrap>学生状态</td>
          <td class="TDHead" nowrap>在线时长</td>
          <td class="TDHead" nowrap>最后登陆时间</td>
          <td class="TDHead" nowrap>操 作</td>
        <!--  <td class="TDHead" nowrap>登陆记录</td>-->
        </tr>
<?php
	$member_result=$db->query($sql." limit ".($page-1)*($pagesize).",$pagesize");
	while($member_row = $db->fetch_array($member_result))
	{
        $dueid=fs_get_objinfo("nettteach_class", "id", $member_row['classid'], "dueid");
?>
		<tr id="t<?php echo($member_row["id"]);?>" onclick="click_tr('<?php echo ($member_row["id"]);?>')" onMouseOver="bgColor='#FF8899'" onMouseOut="bgColor='FFFFFF'" title=单击选中 align="center">
			<td height="27"><input name='id[]' type='checkbox' id="c<?php echo($member_row["id"]);?>" value='<?php echo ($member_row["id"]);?>' onclick="click_tr('<?php echo ($member_row["id"]);?>')"></td>
			<td><?php echo($member_row['passport']);?></td>
            <td><a href="?do=addmember&member_id=<?php echo ($member_row["id"]);?>&dueid=<?php echo $dueid;?>"><?php echo($member_row["realname"]);?></a></td>
            <td><?php echo fs_get_usedname("nettteach_due",$dueid); ?></td>
            <td><?php echo(fs_get_usedname(TABLE_CLASS,$member_row['classid'])); ?></td>
            <td><?php echo(fs_get_usename($member_row['classid']))?></td>
			<td><?php echo($member_row['tel']);?></td>
			<td><?php echo($member_row['email']);?></td>
			<td><?php echo(fs_get_member_state($member_row['state']));?></td>
            <td><?php if($member_row['onlinetime'] !=null){echo($member_row['onlinetime']);}else{echo 0;}?> 分</td>
			<td><?php if($member_row['lastlogintime'] !=0){echo(date('Y-m-d H:i:s',$member_row['lastlogintime']));}else{echo "暂无登陆记录";}?></td>
			<td><a href="?do=addmember&member_id=<?php echo ($member_row["id"]);?>&dueid=<?php echo $dueid;?>">编缉</a></td>
			<!--<td><a href="admin_teacher_record.php?member_id=<?php echo ($member_row["id"]);?>">查看登陆记录</a></td>-->
		</tr>
		<tr>
			<td height=1 colspan=10 bgcolor="#E8F1FF" onMouseOver="bgColor='#FF8899'" onMouseOut="bgColor='E7sxE7sxE7sx'"></td>
		</tr>
<?php
	}
?>
	</table>	</div>	</div>
	</form>
	
	
	

	<center>
<?php
/*分页示例:

pager(传入URL , 数据总数 , 开始条数 , 每页数目)
*/
echo(pager('?p={page}',$recordcount,($page-1)*($pagesize),$pagesize));		
?>
</center>
	</td>
	</tr>
	</table>

<?php
}
//根据表名 id 返回name值 qzr
function fs_get_usedname($tablename,$i)
{
	if ( $i=='' || is_null($i) || !is_numeric($i))	{return '无';break;}
	global $db;
	$sql	=	"select name from ".$tablename." where id=$i ";
	$result =	$db -> query($sql);
	$row	=	$db -> fetch_array($result);
	return	$row['name'];
}
//根据班级id 返回系名和专业名 qzr
function fs_get_usename($i)
{
	if ( $i=='' || is_null($i) || !is_numeric($i))	{return '无';break;}
	global $db;
	$sql	=	"select d.name as departmentname,m.name as majorname from nettteach_class c,nettteach_department d,nettteach_major m where c.id=$i and c.majorid = m.id and c.departmentid = d.id ";
        $result =	$db -> query($sql);
	$row	=	$db -> fetch_array($result);
	return	$row['departmentname']."/".$row['majorname'];
}
?>


<!--
编缉学生开始
-->
<?php
function addmember()
{
    global $db;
	$member_id = fs_get_value("member_id");
	if($member_id != ''){
		$sql = "select * from nettteach_member where id = ".$member_id;
		$member_result = $db -> query($sql);
		$member_row = $db -> fetch_array($member_result);
        $departmentid = fs_get_objinfo("nettteach_class", "id", $member_row['classid'], "departmentid");
        $majorid = fs_get_objinfo("nettteach_class", "id", $member_row['classid'], "majorid");
        $dueid=fs_get_objinfo("nettteach_class", "id", $member_row['classid'], "dueid");
	}
?>
<script type="text/javascript">
function getUsername(str){
    if (str.length==0){ 
		document.getElementById("user_info").innerHTML="* 不能为空！";
		return false;
	}
    var url="ajax/getparts.php?u="+str;
	url=url+"&sid="+<?php echo $member_id?>;
    $.ajax({
         url: url,
         cache: false,
         dataType: "html",
         success:function(html){
			　 $("#user_info").html(html);
			  }
    });
}
</script>
<script src="./js/Main.js"></script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="CContent">
		<tr>
		    <th class="CTitle">学生管理</th>
		</tr>	
		<tr>
			<td class="CPanel">
    <div class="SubMenu">
		<a href="teacher_student.php?">学生管理</a> | 
		<a href="teacher_student.php?do=addteacher">添加学生</a> | 
		<a href="teacher_student.php?do=searchmember">搜索学生</a> | 
                <a href="teacher_student.php?do=batchadd">批量导入</a>
		<!--<a href="admin_teacher_record.php">学生登陆记录</a>-->
	</div>
			</td>
		</tr>	
		<tr>
			<td>
			<div class="middle_right_list" style="font-size:13px;">
			<form name="addform" method="post" action="?do=add&member_id=<?php echo($member_id);?>">
			<fieldset>
				<legend>编缉学生</legend>
				    带<span style="color:#FF0000;">*</span>的必填。<br/><br/>
                    <label>登陆账号：</label><input name="username" type="text"  class="text" value="<?php echo($member_row['passport']);?>" onblur="getUsername(this.value)" ><span id="user_info" style="color:#FF0000;">*只能输入4~30个字母或数字</span><br/><br/>
					<label>登陆密码：</label><input name="password" type="text"  class="text" value=""><span style="color:#FF0000;">不修改勿填</span><br/><br/>
                    <label>学生姓名：</label><input name="member_name" type="text"  class="text" value="<?php echo($member_row['realname']);?>" /><span style="color:#FF0000;">*</span><br/><br/>
                    <label>届&nbsp;：</label>       
                        <select name="dueid" id="dueid" style="width:300px;">
                                <?php
                                $sql="select* from nettteach_due where 1=1";
                                $result=mysql_query($sql);
                                //循环列出选项
                                        while($rows=mysql_fetch_array($result))
                                {?>
                                        <option value="<?php echo $rows['id'];?>" <?php if($rows['id']==$dueid){echo "selected";}?>><?php echo $rows['name'];?></option>
                                <?php } ?>
                        </select><span style="color:#FF0000;">*</span><br/><br/>
                        <label>院系：</label>
                        <select name="departid" id="departid" style="width:300px;" >
                                        <option value="-1">请选择系</option>
                                        <?php
                                        $sql="select* from nettteach_department where 1=1";
                                        $result=mysql_query($sql);
                                        //循环列出选项
                                                while($rows=mysql_fetch_array($result))
                                        {?>
                                                <option value="<?php echo $rows['id']; ?>" <?php if($rows['id']==$departmentid)echo 'selected'; ?>><?php echo $rows['name'];?></option>
                                        <?php } ?>
                        </select><span style="color:#FF0000;">*</span><br/><br/>
                     <label>专业：</label>
                        <select name="majorid" id="majorid" style="width:300px;">
                             <option value="-1">请选择专业</option>
                                        <?php
                                        $sql="select* from nettteach_major where departmentid=".$departmentid;
                                        $result=mysql_query($sql);
                                        //循环列出选项
                                                while($rows=mysql_fetch_array($result))
                                        {?>
                                        <option value="<?php echo $rows['id']; ?>" <?php if($rows['id']==$majorid)echo 'selected'; ?>><?php echo $rows['name'];?></option>
                                        <?php } ?>
                        </select><span style="color:#FF0000;">*</span><br/><br/> 
                     <label>班级：</label>
                        <select name="classid" id="classid" style="width:300px;">
                             <option value="-1">请选择班级</option>
                                        <?php
                                        $sql="select * from nettteach_class where dueid=".$dueid." and majorid=".$majorid;echo $sql;
                                        $result=mysql_query($sql);
                                        //循环列出选项
                                                while($rows=mysql_fetch_array($result))
                                        {?>
                                        <option value="<?php echo $rows['id']; ?>" <?php if($rows['id']==$member_row['classid'])echo 'selected'; ?>><?php echo $rows['name'];?></option>
                                        <?php } ?>
                        </select><span style="color:#FF0000;">*</span><br/><br/> 
					<label>学生状态：</label>
					<select name="state" style="width:300px;">
					    <option value="0" <?php if($member_row['state'] == 0){echo("selected");}?>>未激活</option>
					    <option value="1" <?php if($member_row['state'] == 1){echo("selected");}?>>已激活</option>
					</select><span style="color:#FF0000;">*</span><br/><br/>
                    <label>联系电话：</label><input name="tel" type="text"  class="text" value="<?php echo($member_row['tel']);?>"><br/><br/>
					<label>电子邮件：</label><input name="email" type="text"  class="text" value="<?php echo($member_row['email']);?>"><br/><br/>
                    <label>登陆次数：</label><input name="logintimes" type="text"  class="text" value="<?php echo($member_row['logintimes']);?>"><br/><br/>
                    <div class="submit">
					<label></label><input type="hidden" name="test_major" value="1" /><input type="submit" class="sub" value="确认提交" onclick="return CheckStd();"/>&nbsp;&nbsp;&nbsp;&nbsp;<a class="lj" href="teacher_student.php">返回列表</a></div>
                   </fieldset>
			</form>
			</div>
			</td>
		</tr>
	</table>
<?php
}
function do_addmember(){
    global $db;
	$member_name = fs_get_value("member_name");
	$username = fs_get_value("username");
	$password = fs_get_value("password");
	$tel = fs_get_value("tel");
	$email = fs_get_value("email");
        
	$classid = fs_get_value("classid");
//	$majorid = fs_get_value("majorid");
//	$departid = fs_get_value("departid");
	$state = fs_get_value("state");
	$logintimes = fs_get_value("logintimes");
	$lastlogintime = fs_get_value("lastlogintime");
	$onlinetime = fs_get_value("onlinetime");
	$registerdate = strtotime(fs_get_value("registerdate"));
	
        
                //添加学生
                if(fs_get_value("member_id") == ''){
                        if($username != '' && $member_name != ''){
                                $num = $db -> row_count(TABLE_MEMBER,"passport = '".$username."'");
                                if($num>0)
                                {
                                        fs_showmsg("该用户名已存在！");
                                        exit();
                                }else
                                {
                                        $sql = "insert into nettteach_member (passport,realname,type) value ('".$username."','".$member_name."','3')";
                                        $db->query($sql);
                                        $id = mysql_insert_id();
                                }
                        }
                }
                else{
                        //修改学生
                        $id = fs_get_value("member_id");
                        if($username != '' && $member_name != ''){
                                $sql = "update nettteach_member  set passport = '".$username."',realname = '".$member_name."' where id = ".$id;
                                $db -> query($sql);
                        }
                }
                if($id == '')
                {
                       fs_showmsg("添加错误！");
                       exit();  
                }
                if($password != ''){
                        $sql = "update nettteach_member  set password = '".fs_sha1($password)."' where id = ".$id;
                        $db -> query($sql);
                }
//                if($tel != ''){
                        $sql = "update nettteach_member set tel = '".$tel."' where id = ".$id;
                        $db -> query($sql);
//                }
//                if($email != ''){
                        $sql = "update nettteach_member set email = '".$email."' where id = ".$id;
                        $db -> query($sql);
//                }
                if($classid != '-1'){
                        $sql = "update nettteach_member set classid = ".$classid." where id = ".$id;
                        $db -> query($sql);
                }
                if($state != ''){
                        $sql = "update nettteach_member set state = ".$state." where id = ".$id;
                        $db -> query($sql);
                }
                else{
                        $sql = "update nettteach_member set state = null where id = ".$id;
                        $db -> query($sql);
                }
                if($logintimes != ''){
                        $sql = "update nettteach_member set logintimes = ".$logintimes." where id = ".$id;
                        $db -> query($sql);
                }
                if($onlinetime != ''){
                        $sql = "update nettteach_member set onlinetime = ".$onlinetime." where id = ".$id;
                        $db -> query($sql);
                }
                if($registerdate != ''){
                        $sql = "update nettteach_member set registerdate = ".$registerdate." where id = ".$id;
                        $db -> query($sql);
                }
                if(fs_get_value("member_id") == ''){
                        fs_showmsg("添加成功！");
                }
                else{
                        fs_showmsg("修改成功！");
                }
        
}
?>
<!--
编缉学生结束
-->
<!--
添加学生开始
-->
<?php
function addteacher()
{
    global $db;
?>
<script type="text/javascript">
function getUsername(str){
    if (str.length==0){ 
		document.getElementById("user_info").innerHTML="* 不能为空！";
		return false;
	}
    var url="ajax/getparts.php?u="+str;
	url=url+"&sid=";
    $.ajax({
         url: url,
         cache: false,
         dataType: "html",
         success:function(html){
			　 $("#user_info").html(html);
			  }
    });
}
</script>
<script src="./js/Main.js"></script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="CContent">
		<tr>
		    <th class="CTitle">学生管理</th>
		</tr>	
		<tr>
			<td class="CPanel">
    <div class="SubMenu">
		<a href="teacher_student.php?">学生管理</a> | 
		<a href="teacher_student.php?do=addteacher">添加学生</a> | 
		<a href="teacher_student.php?do=searchmember">搜索学生</a> | 
                <a href="teacher_student.php?do=batchadd">批量导入</a>
		<!--<a href="admin_teacher_record.php">学生登陆记录</a>-->
	</div>
			</td>
		</tr>	
		<tr>
			<td>
			<div class="middle_right_list" style="font-size:13px;">
			<form name="addform" method="post" action="?do=add&member_id=<?php echo($member_id);?>">
			<fieldset>
                           
				<legend>添加学生</legend>
				    带<span style="color:#FF0000;">*</span>的必填。<br/><br/>
					<label>登陆账号：</label><input name="username" type="text"  class="text" onblur="getUsername(this.value)" ><span id="user_info" style="color:#FF0000;">*只能输入4~30个字母或数字</span><br/><br/>
                    <label>登陆密码：</label><input name="password" type="text"  class="text" value="123456"><span style="color:#FF0000;">*</span><br/><br/>
                    <label>学生姓名：</label><input name="member_name" type="text"  class="text" /><span style="color:#FF0000;">*</span><br/><br/>
                    <label>届：</label>       
                        <select name="dueid" id="dueid" style="width:300px;">
                                <option value="-1">请选择届</option>
                                <?php
                                $sql="select* from nettteach_due where 1=1";
                                $result=mysql_query($sql);
                                //循环列出选项
                                        while($rows=mysql_fetch_array($result))
                                {?>
                                        <option value=<?php echo $rows['id']; ?>><?php echo $rows['name'];?></option>
                                <?php } ?>
                        </select> <span style="color:#FF0000;">*</span><br/><br/>
                    <label>院系：</label>
                        <select name="departid" id="departid" style="width:300px;">
                                <option value="-1">请选择系</option>
                        </select><span style="color:#FF0000;">*</span><br/><br/>
                    <label>专业：</label>
                        <select name="majorid" id="majorid" style="width:300px;">
                                <option value="-1">请选择专业</option>
                        </select><span style="color:#FF0000;">*</span><br/><br/>
                    <label>班级：</label>
                        <select name="classid" id="classid" style="width:300px;">
                                <option value="-1">请选择班级</option>
                        </select><span style="color:#FF0000;">*</span><br/><br/>
                    <label>联系电话：</label><input name="tel" type="text"  class="text" value="<?php echo($member_row['tel']);?>"><br/><br/>
					<label>电子邮件：</label><input name="email" type="text"  class="text" value="<?php echo($member_row['email']);?>"><br/><br/>
					<label>学生状态：</label>
					<select name="state" style="width:120px;">
					    <option value="0" >未激活</option>
					    <option value="1" selected>已激活</option>
					</select><span style="color:#FF0000;">*</span><br/><br/>
<!--					<label>登陆次数：</label><input name="logintimes" type="text"  class="text" value="<?php echo($member_row['logintimes']);?>"><br/><br/>-->
					<input name="registerdate" type="hidden"  class="text" value="<?php if($member_id == ''){echo(date("Y-m-d",time()));}else{echo date("Y-m-d",$member_row['registerdate']);}?>"><br/><br/>		
					<div class="submit">
					<label></label><input type="hidden" name="test_major" value="1" /><input type="submit" class="sub" value="确认提交" onclick="return CheckStd();"/>&nbsp;&nbsp;&nbsp;&nbsp;<a class="lj" href="teacher_student.php">返回列表</a></div>
             </fieldset>
			</form>
			</div>
			</td>
		</tr>
	</table>
<?php
}
?>
<!--
添加学生结束
-->
<?php
function searchmember()
{
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="CContent">
		<tr>
		    <th class="CTitle">学生管理</th>
		</tr>	
		<tr>
			<td class="CPanel">
    <div class="SubMenu">
		<a href="teacher_student.php?">学生管理</a> | 
		<a href="teacher_student.php?do=addteacher">添加学生</a> | 
		<a href="teacher_student.php?do=searchmember">搜索学生</a> | 
                <a href="teacher_student.php?do=batchadd">批量导入</a>
		<!--<a href="admin_teacher_record.php">学生登陆记录</a>-->
	</div>
			</td>
		</tr>	
		<tr>
			<td>
			<div class="middle_right_list">
			<form name="searchform" method="post" action="?">
			<fieldset>
				<legend>搜索学生</legend><br><br>
					<label><div align="right">学生姓名：</div></label><input name="member_name" type="text" class="text" value="" /><br/><br/>
					<label><div align="right">登陆账号：</div></label><input name="username" type="text"  class="text" value=""><br/><br/>
					<!--<label><div align="right">联系电话：</div></label><input name="tel" type="text" style="width:400px;" class="text" value=""><br/>-->
					<label><div align="right">电子邮件：</div></label><input name="email" type="text"  class="text" value=""><br/><br/>
                   <label>届：</label>       
                        <select name="dueid" id="dueid" style="width:300px;">
                                <option value="-1">请选择届</option>
                                <?php
                                $sql="select* from nettteach_due where 1=1";
                                $result=mysql_query($sql);
                                //循环列出选项
                                        while($rows=mysql_fetch_array($result))
                                {?>
                                        <option value=<?php echo $rows['id']; ?>><?php echo $rows['name'];?></option>
                                <?php } ?>
                        </select> <br/><br/>
                    <label>院系：</label>
                        <select name="departid" id="departid" style="width:300px;">
                                <option value="-1">请选择系</option>
                        </select><br/><br/>
                    <label>专业：</label>
                        <select name="majorid" id="majorid" style="width:300px;">
                                <option value="-1">请选择专业</option>
                        </select><br/><br/>
                    <label>班级：</label>
                        <select name="classid" id="classid" style="width:300px;">
                                <option value="-1">请选择班级</option>
                        </select><br/><br/>
					<div class="submit">
					<label></label><input type="submit" value="确认搜索"/>&nbsp;&nbsp;&nbsp;&nbsp;<a class="lj" href="teacher_student.php">返回列表</a></div>
			</fieldset>
			</form>
			</div>
			</td>
		</tr>
	</table>
<?php
}
?>

<?php
//删除学生
function delete_member()
{
    global $db;
	$i=0;
	$member_id = $_POST['id'];
	if($member_id != '')
        {
                while($member_id){
                    if($member_id[$i]==null) break;
                        $sql = "delete from nettteach_member where id = ".$member_id[$i]."";
                    $db -> query($sql);
                    $i++;
                }
                fs_showmsg('删除成功!','teacher_student.php?do=manage');
        }else
        {
                fs_showmsg('请选择要删除的学生!');
        }
}
?>

<?php
//批量导入
function batchadd()
{
    global $db;
?>
<script src="./js/ajax.js"></script>
<script src="./js/Main.js"></script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="CContent">
		<tr>
		    <th class="CTitle">学生管理</th>
		</tr>	
		<tr>
			<td class="CPanel">
    <div class="SubMenu">
		<a href="teacher_student.php?">学生管理</a> | 
		<a href="teacher_student.php?do=addteacher">添加学生</a> | 
		<a href="teacher_student.php?do=searchmember">搜索学生</a> | 
                <a href="teacher_student.php?do=batchadd">批量导入</a>
		<!--<a href="admin_teacher_record.php">学生登陆记录</a>-->
	</div>
			</td>
		</tr>	
		<tr>
			<td>
			<div class="middle_right_list" style="font-size:13px;">
			<form name="addform" method="post" action="uploadexcel.php" enctype="multipart/form-data">
			<fieldset>
                           
				<legend>批量添加学生</legend>
                    <label>批量导入： </label><input type="hidden" name="leadExcel" value="true">   
                    <input type="file" name="file">  支持.xls文件,两列(登陆账号,姓名),从第二行开始录入<br/><br/>
                     <label>届：</label>       
                        <select name="dueid" id="dueid" style="width:300px;">
                                <option value="-1">请选择届</option>
                                <?php
                                $sql="select* from nettteach_due where 1=1";
                                $result=mysql_query($sql);
                                //循环列出选项
                                        while($rows=mysql_fetch_array($result))
                                {?>
                                        <option value=<?php echo $rows['id']; ?>><?php echo $rows['name'];?></option>
                                <?php } ?>
                        </select> <br/><br/>
                    <label>院系：</label>
                        <select name="departid" id="departid" style="width:300px;">
                                <option value="-1">请选择系</option>
                        </select><br/><br/>
                    <label>专业：</label>
                        <select name="majorid" id="majorid" style="width:300px;">
                                <option value="-1">请选择专业</option>
                        </select><br/><br/>
                    <label>班级：</label>
                        <select name="classid" id="classid" style="width:300px;">
                                <option value="-1">请选择班级</option>
                        </select><br/><br/>
					<label>登陆密码：</label><input name="password" type="text"  class="text" value="123456"><br/><br/>
                    <label>学生状态：</label>
                        <select name="state" style="width:300px;">
                            <option value="0" >未激活</option>
                            <option value="1" selected>已激活</option>
                        </select><br/><br/><input name="registerdate" type="hidden"  class="text" value="<?php if($member_id == ''){echo(date("Y-m-d",time()));}?>">
					<label>注册时间：</label><input name="date" type="text"  class="text" value="<?php if($member_id == ''){echo(date("Y-m-d",time()));}?>"><br/><br/>		
					<div class="submit">
					<label></label><input type="hidden" name="test_major" value="1" /><input type="submit" class="sub" value="确认提交" onclick="return CheckStd();"/>&nbsp;&nbsp;&nbsp;&nbsp;<a class="lj" href="teacher_student.php">返回列表</a></div>
                 </fieldset>
			</form>
			</div>
			</td>
		</tr>
	</table>
<?php
}
?>